/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.ls.controller;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * <p>Project: likeshop - Show
 * <p>Powered By webrx
 * <p>Created By IntelliJ IDEA On 2021-03-31 09:06:50
 * <p>Description :
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 15
 */
@Controller
public class Show {
    @GetMapping("/user") //默认使用/WEB-INF/templates/user.ftl 模板文件渲染
    public void user(){
    }

    @GetMapping("/m0") //默认使用/WEB-INF/templates/user.ftl 模板文件渲染
    public String useraa(Model m){
        m.addAttribute("name","李四");
        m.addAttribute("age",18);
        m.addAttribute("addrs",new String[]{"郑州","北京","天津","上海"});
        return "user";
    }


    @GetMapping("/m1") @ResponseBody
    public String m1(){
        return "hello 中国";
    }

    @RequestMapping("/m2")
    public void m2(PrintWriter out){
        out.print("hello 中国88");
    }

    @GetMapping("/m3")
    public void m3(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        System.out.println("中文ch");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<meta charset=\"utf-8\">");
        out.println("<title>玉灵 QQ:7031633 Email:webrx@126.com</title>");
        out.println("<meta name=\"keywords\" content=\"关键字\">");
        out.println("<meta name=\"description\" content=\"简介\">");
        out.println("</head>");
        out.println("<body>");

        out.println("<h3>Hello World  中文效果</h3>");

        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }
}
